import { onBeforeRouteLeave, onBeforeRouteUpdate, createRouter, createWebHistory, RouteRecordRaw } from 'vue-router'
import HomeView from '../views/HomePage.vue/HomeView.vue'
import Setting from '../views/Setting.vue'
// 1. 定义路由组件， 注意，这里一定要使用 文件的全名（包含文件后缀名）
// import test from './test/test.vue'
import login from '../views/Login/login.vue'


// 配置路由 routes: Array是指定数组类型 TS语法
// 配置默认显示路由
// { 
//   path: '/',
//   name: login,
//   component: login
// },

// {path:'/路由名称',component: 组件名}
// {path:'/test',component: test}
const routes: Array<RouteRecordRaw> = [//重定向
  {
    path: '/',
    redirect: "/login"
  },
  // 配置默认显示路由
  {
    path: '/login',
    name: 'login',
    component: login
  },
  {
    path: '/lin',
    name: 'lin',
    component: () => import('../views/Lin/lin.vue'),
    redirect: "/lin/home",
    children: [
      {
        path: 'home',
        name: 'home',
        component: HomeView,
      },
      {
        path: 'setting',
        name: 'setting',
        component: Setting
      },
      {
        path: 'storeManagement',
        name: 'storeManagement',
        component: () => import('../views/storeManagement/storeManagement.vue')
      },
      {
        path: 'Business',
        name: 'Business',
        component: () => import('../views/Business.vue')
      },
      {
        path: 'commit',
        name: 'commit',
        component: () => import('../views/Commit/commit.vue')
      },
      {
        path: 'dishes',
        name: 'dishes',
        component: () => import('../views/Dishes/dishes.vue')
      },
      {
        path: 'special',
        name: 'special',
        component: () => import('../views/ContentManagement/Special/Special.vue')
      },
      {
        // 添加店铺
        path: 'addform',
        name: 'addform',
        component: () => import('../components/outForm.vue')
      }

    ]
  },
  // 特价菜
]
// Vue-router新版本中，需要使用createRouter来创建路由
const router = createRouter({
  // 指定路由的模式,此处使用的是History模式
  history: createWebHistory(process.env.BASE_URL),
  routes
})

export default router
